package com.pattern.demo;

import com.pattern.demo.javaapi.CurrentConditionsDisplayByJdk;
import com.pattern.demo.javaapi.WeatherDataByJdk;
import com.pattern.demo.protogenesis.CurrentConditionsDisplay;
import com.pattern.demo.protogenesis.CurrentWindDisplay;
import com.pattern.demo.protogenesis.WeatherData;

/**
 * @ClassName: WeatherStation  天气站测试
 * @Description:
 * @Date: 2020/8/27 15:32
 * @Author: Song JinGen
 */
public class WeatherStation {
    public static void main(String[] args) {
        System.out.println("-----------手写观察者模式--------------");
        //创建WeatherData对象
        WeatherData weatherData = new WeatherData();
        //把对象传给CurrentConditionsDisplay看板
        CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData);
        CurrentWindDisplay currentWindDisplay = new CurrentWindDisplay(weatherData);
        //模拟天气变化
        weatherData.setMeasurements(20,30,50.5f, "3", "天气晴朗，风力中等");
        weatherData.setMeasurements(30,70,50.5f, "5", "多云转小雨，风力强力");
        weatherData.setMeasurements(20,60,50.5f, "1", "晴转多云，微风");

        System.out.println("-----------用java api 实现观察者模式--------------");
        WeatherDataByJdk weatherDataByJdk = new WeatherDataByJdk();
        CurrentConditionsDisplayByJdk currentConditionsDisplayByJdk = new CurrentConditionsDisplayByJdk(weatherDataByJdk);
        weatherDataByJdk.setMeasurements(20,30,50.5f, "3", "天气晴朗，风力中等");
        weatherDataByJdk.setMeasurements(30,70,50.5f, "5", "多云转小雨，风力强力");
        weatherDataByJdk.setMeasurements(20,60,50.5f, "1", "晴转多云，微风");

    }
}
